#define _CRT_SECURE_NO_WARNINGS 1
#include <string>
#include <iostream>
using namespace std;

class Solution {
public:

    bool isNumber(string s) {
        int i = 0;
        for (; i < s.size(); ++i) {
            if (s[i] == 'e' || s[i] == 'E')
                break;
        }

        bool ans = true;
        ans &= _isNumber1(s.substr(0, i));
        if(i != s.size())
            ans &= _isNumber2(s.substr(i + 1));
        return ans;
    }
private:
    bool _isNumber1(string s) {
        bool dotFlag = true;
        bool opFlag = true;

        for (int i = 0; i < s.size(); ++i) {
            if ((s[i] == '+' || s[i] == '-')) {
                if(!opFlag)
                    return false;
            }
                

            if (s[i] == '.') {
                if(dotFlag)
                    dotFlag = false;
                else
                    return false;
            }

            if (s[i] >= 'a' && s[i] <= 'z')
                return false;
            if (s[i] >= 'A' && s[i] <= 'Z')
                return false;

            if (i == 0)
                opFlag = false;
        }
        return true;
    }


    bool _isNumber2(string s) {
        if (s.size() == 0)
            return true;
        bool opFlag = true;
        for (int i = 0; i < s.size(); ++i) {
            if ((s[i] == '+' || s[i] == '-')) {
                if (!opFlag)
                    return false;
            }

            if (s[i] >= '0' && s[i] <= '9')
                continue;
            else
                return false;

            if (i == 0)
                opFlag = false;
        }
        return true;
    }
};
int main() {
    string s = "0089";
    Solution().isNumber(s);
    return 0;
}